<?php
/**
 * @package		Joomla.Site
 * @subpackage	mod_event_articles
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;

require_once JPATH_SITE.'/components/com_content/helpers/route.php';

/**
 * @package		Joomla.Site
 * @subpackage	mod_event_articles
 * @since		1.5
 */
class modStatsHelper
{
	static function getList()
	{
		$db		= JFactory::getDbo();
		$query	= $db->getQuery(true);
		
		$query->select('c.*, cat.id AS category_id, cat.title AS category_title, cat.alias AS category_alias')
			->from('#__content c')
			->join('INNER', '#__categories cat ON cat.id = c.catid')
			->where('cat.extension = "com_content"')
			->where('c.is_event = 1')
			->order('c.id DESC')
		;
		
		$db->setQuery($query, 0, 30);
		$items = $db->loadObjectList();
		
		foreach ($items as &$item) {
			$item->slug = $item->id.':'.$item->alias;
			$item->catslug = $item->catid.':'.$item->category_alias;
		
			$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
		}
		
		return $items;
	}
}
